package cn.tianyigps.tianyigpskafka.task.manger;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author: WEI.YUAN
 * @Descirption:生产者
 * @Date: 2019/4/26_18:44
 */
@Component
@Slf4j
public class NewTaskManager {
    @Autowired
    KafkaTemplate kafkaTemplate;

    public Map<String, Object> distributeTask(String taskType,String json){

        Map<String, Object> map = new HashMap<>();
            try {
                kafkaTemplate.send(taskType, json);
            } catch (Exception e) {
                map.put("kafkaSendErr","task数据发送失败");
                e.printStackTrace();
            }
        map.put("task",json);
        return map;
    }

}
